﻿using Whoever.Patterns.Business;

using EditorialProyectos.Business.Entities;
using EditorialProyectos.DataAccess.Repositories;
using System.Collections.Generic;
using System.Linq;

namespace EditorialProyectos.Business
{
    public class BenefitManager : Manager<Benefit>
    {
        public BenefitManager()
            : base(RepositoryFactory.BenefitRepository)
        {

        }

        public ICollection<Benefit> GetByProjectId(int projectId)
        {
            var benefits = ManagerRepository.BenefitRepository.GetAll();
            var resultBenefits = benefits.Where(u => u.ProjectId == projectId).ToList();
            foreach(var benefit in resultBenefits)
            {
                benefit.Project = null; // TODO: MATIAS - Le saco el projectId para evitar la relación circular.
            }

            return resultBenefits.ToList();
        }

    }
}
